using System;
using System.Collections.Generic;
using System.Text;

namespace Deepcode.Flux.Core.Systems.UI.Menus
{
	/// <summary>
	/// MenuToolLink represents a menu entry that opens it's url in the content area
	/// of the main menuing system's windows. This keeps the menu active rather than opening
	/// in the full client area.
	/// </summary>
	public class MenuToolLink : IMenuEntry
	{
		private string _HREF = "";
		private string _Caption = "";
		private string _Title = "";
		private System.Web.UI.Page _Owner = null;

		/// <summary>
		/// Construct a new link from the parameters specified
		/// </summary>
		/// <param name="owner"></param>
		/// <param name="href"></param>
		/// <param name="caption"></param>
		/// <param name="title"></param>
		public MenuToolLink(System.Web.UI.Page owner, string href, string caption, string title)
		{
			_HREF = href;
			_Caption = caption;
			_Title = title;
			_Owner = owner;
		}
		/// <summary>
		/// Return the navigation url component. In this case it returns
		/// javascrpt to instruct the content frame to navigate to the resolved
		/// Href specified.
		/// </summary>
		public string NavigateUrl
		{
			get
			{
				return String.Format("javascript:parent.ContentJS.Navigate('{0}', '{1}');",
					_Owner.ResolveUrl(_HREF),
					_Title);
			}
		}
		/// <summary>
		/// Return the caption for the hyperlink
		/// </summary>
		public string Text
		{
			get
			{
				return _Caption;
			}
		}
		/// <summary>
		/// Return the target. For this type, we always use javascript to tell the content
		/// frame to navigate, so this will always be empty.
		/// </summary>
		public string Target
		{
			get
			{
				return String.Empty;
			}
		}
	}
}
